#ifndef QNMTRANSLATION_H
#define QNMTRANSLATION_H

#include <QObject>
#include <QtGui>
#include <QtDeclarative>

#include <QTranslator>
#include <QLocale>

class QNMTranslation : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString forceLanguage READ getEmptyString NOTIFY languageChanged)

    QTranslator *translator_ru;
    QTranslator *translator_hu;

    inline void setAuto() {
        setEnglish();
        QLocale lcl;
        if(lcl.language() == QLocale::English) {
            setEnglish();
        } else if(lcl.language() == QLocale::Russian) {
            setRussian();
        } else if(lcl.language() == QLocale::Hungarian) {
            setHungarian();
        }
    }

    inline void setEnglish() {
        qApp->removeTranslator(translator_ru);
        qApp->removeTranslator(translator_hu);
    }

    inline void setRussian() {
        qApp->removeTranslator(translator_hu);
        translator_ru->load( "/opt/QNetMan2/qml/QNetMan2/i18n/qnetman2_rus.qm" );
        qApp->installTranslator(translator_ru);
    }

    inline void setHungarian() {
        qApp->removeTranslator(translator_ru);
        translator_hu->load( "/opt/QNetMan2/qml/QNetMan2/i18n/qnetman2_hun.qm" );
        qApp->installTranslator(translator_hu);
    }

public:
    explicit QNMTranslation(QObject *parent = 0);

    inline QString getEmptyString() {
        return "";
    }
    Q_INVOKABLE void selectLanguage( QString language );
    
signals:
    void languageChanged();
    
public slots:
    
};

#endif // QNMTRANSLATION_H
